package Demo1;

import java.util.Scanner;

public class T19 {
    private static volatile int flag = 0;
    public static void main(String[] args) {
        Thread thread1 = new Thread(()->{
            while(flag == 0){

            }
            System.out.println("线程结束");
        });

        Thread thread2 = new Thread(()->{
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入flag的值");
            flag = scanner.nextInt();
        });
        thread1.start();
        thread2.start();
    }
}
